<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>提现申请</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-8">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>提现申请</h5>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="commentForm">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">提现金额：</label>
                                <div class="col-sm-3 pr3">
                                    <input id="amount" name="amount" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                </div>元
                                <span class="cred t1"></span>
                            </div>
                            <eq name='gm_admin.role' value='1'>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-4 cgray">
                                        可提金额：<span id="rebate">{$rebate}</span>
                                    </div>
                                </div>
                            </eq>
                            
                            <div class="form-group">
                                <label class="col-sm-4 control-label">收款方式：</label>
                                <div class="col-sm-3 pr3">
                                    <select class="input-sm form-control input-s-sm inline" name="payment_type" id="payment_type">
                                    <option value="">请选择收款方式</option>
                                    <option value="1">支付宝</option>
                                    <option value="2">微信</option>
                                    <option value="3">银行卡</option>
                                </select>
                                </div>
                                <span class="cred t2"></span>
                            </div>
                            <div class="form-group hide" id="bank_div">
                                <label class="col-sm-4 control-label ">开户行：</label>
                                <div class="col-sm-6">
                                    <input id="bank" name="bank" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                </div>
                                <span class="cred t3"></span>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">收款账号：</label>
                                <div class="col-sm-6">
                                    <input id="payment_no" name="payment_no" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                </div>
                                <span class="cred t4"></span>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-4">
                                    <button class="btn btn-primary" type="button">提交申请</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

        </div>

    </div>


    <!-- 全局js -->
    <script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>

    <!-- jQuery Validation plugin javascript-->
    <script src="__PUBLIC__/admin/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="__PUBLIC__/admin/js/plugins/validate/messages_zh.min.js"></script>

    <!-- <script src="__PUBLIC__/admin/js/demo/form-validate-demo.js"></script> -->
    <script type="text/javascript">
    $('#payment_type').change(function(){
        if ($(this).val()=='3') {
            $('#bank_div').removeClass('hide');
        }else{
            $('#bank_div').addClass('hide');
        }
    })
        $(".btn-primary").click(function() {
            var amount=$.trim($("#amount").val());
            var payment_type=$.trim($("#payment_type").val());
            var bank=$.trim($("#bank").val());
            var payment_no=$.trim($("#payment_no").val());
            if ( amount== '') {
                $('.t1').html('请输入提现金额！');
                return false;
            }else{
                $('.t1').html('');
            }
            if ({$gm_admin.role}==1) {
                if (amount > {$rebate}) {
                    $('.t1').html('余额不足！');
                    return false;
                }else{
                    $('.t1').html('');
                }
            }
            if (payment_type == '') {
                $('.t2').html('请选择收款方式！');
                return false;
            }else{
                $('.t2').html('');
            }
            if (payment_type == '3') {
                if (bank == '') {
                    $('.t3').html('请输入开户行！');
                    return false;
                }else{
                    $('.t3').html('');
                }
            }
            if (payment_no == '') {
                $('.t4').html('请输入收款账号！');
                return false;
            }else{
                $('.t4').html('');
            }
            var params = {amount:amount,payment_type:payment_type,bank:bank,payment_no:payment_no};
            var url = "{:U('Admin/Admin/withdrawSave')}";
            $.ajax({
                type: "post",
                url: url,
                dataType: "json",
                data: params,
                success: function (data) {
                    if (data == 'success') {
                        alert('提现申请成功，等待审核！');
                        window.location.href = "{:U('Admin/Admin/withdrawApply')}";
                    } else {
                        alert('申请失败！');
                    }
                }
            });
        });
    </script>
    
    

</body>

</html>
